//
//  shisi.m
//  PASystem
//
//  Created by michael on 16/8/23.
//  Copyright © 2016年 czd. All rights reserved.
//

#import "shisi.h"
#import "tzqc.h"
#import "tzxc.h"
#import "hdjg.h"
#import "tzfc.h"
#import "pljy.h"
@implementation shisi
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
    
//    [self initview];
          }
    return self;
}
- (void)setId:(NSString *)id{


//NSLog(@"11%@",id);
 [self initview:id];
}
- (void)initview:(NSString *)id{
NSArray *array = @[@"团组启程",@"团组行程\n及安排",@"活动成果",@"团组返程",@"评价经营\n总结讨论"];
float itemWidth = KScreenWidth /array.count;

for (int i = 0; i<array.count; i++) {

_btn = [UIButton buttonWithType:UIButtonTypeCustom];
    _btn.frame  = CGRectMake(itemWidth*i,0, itemWidth, 40);
[_btn setTitle:array[i] forState:UIControlStateNormal];
_btn.tag = i;
_btn.backgroundColor = [UIColor whiteColor];
_btn.titleLabel.numberOfLines = 0;
     [_btn setTitleColor:[UIColor blueColor ] forState:UIControlStateSelected];

     [_btn setTitleColor:[UIColor blackColor ] forState:UIControlStateNormal];
_btn.titleLabel.font = [UIFont systemFontOfSize: 14.0];
// [_btn.layer setBorderColor:[UIColor blackColor].CGColor];
//    [_btn.layer setBorderWidth:1];
//    [_btn.layer setMasksToBounds:YES];
[_btn addTarget:self action:@selector(action:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:_btn];

}
//剩下的部分的高为(KScreenWidth-64-46)/2

 tzqc *view4 = [[tzqc alloc]initWithFrame:CGRectMake(0, _btn.bottom, KScreenWidth, KScreenHeight-64-46-80)];

    view4.tag = 13;
    view4.id = id;
    _id = id;
[self addSubview:view4];



}

- (void)action:(UIButton *)btn{

        [btn.titleLabel setTextColor:[UIColor blueColor]];
   btn.selected = YES;
   if (self.lastBtn == btn) {
 
        [btn.titleLabel setTextColor:[UIColor blueColor]];
        self.btnClick ++;
        
    }else {

        [self.lastBtn.titleLabel setTextColor:[UIColor blackColor]];
        
        self.btnClick = 0;
    }
    
   self.lastBtn = btn;







for (UIView *view in self.subviews) {
    if (view.tag ==13) {
    [view removeFromSuperview];
    
}
//NSLog(@"%lu",(unsigned long)self.view.subviews.count);
}

if ([[NSString stringWithFormat:@"%ld",(long)btn.tag]isEqualToString:@"0"]) {
    tzqc *view = [[tzqc alloc]initWithFrame:CGRectMake(0, _btn.bottom, KScreenWidth, KScreenHeight-64-46-80)];
      view.id = _id;
//    view.backgroundColor = [UIColor redColor];
    view.tag = 13;
[self addSubview:view];
//[_scrollView addSubview:view];

}
if ([[NSString stringWithFormat:@"%ld",(long)btn.tag]isEqualToString:@"1"]) {
    tzxc *view1 = [[tzxc alloc]initWithFrame:CGRectMake(0, _btn.bottom, KScreenWidth, KScreenHeight-64-46-80)];
//    view1.backgroundColor = [UIColor yellowColor];
    view1.id = _id;
    view1.tag = 13;
[self addSubview:view1];
//[_scrollView addSubview:view1];
}
if ([[NSString stringWithFormat:@"%ld",(long)btn.tag]isEqualToString:@"2"]) {
    hdjg *view2 = [[hdjg alloc]initWithFrame:CGRectMake(0, _btn.bottom, KScreenWidth, KScreenHeight-64-46-80)];
//    view2.backgroundColor = [UIColor greenColor];
     view2.id = _id;
    view2.tag = 13;
    
[self addSubview:view2];
//[_scrollView addSubview:view2];
}
if ([[NSString stringWithFormat:@"%ld",(long)btn.tag]isEqualToString:@"3"]) {
    tzfc *view3 = [[tzfc alloc]initWithFrame:CGRectMake(0, _btn.bottom, KScreenWidth, KScreenHeight-64-46-80)];
//    view3.backgroundColor = [UIColor grayColor];
    view3.tag = 13;
    view3.id = _id;
[self addSubview:view3];
//[_scrollView addSubview:view3];
}
if ([[NSString stringWithFormat:@"%ld",(long)btn.tag]isEqualToString:@"4"]) {
    pljy *view4 = [[pljy alloc]initWithFrame:CGRectMake(0, _btn.bottom, KScreenWidth, KScreenHeight-64-46-80)];
//    view4.backgroundColor = [UIColor grayColor];
    view4.tag = 13;
    view4.id = _id;
[self addSubview:view4];
//[_scrollView addSubview:view3];
}


}

@end
